﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Simple.Common.EasyUICommon
{
    public class SimpleResult
    {
        /// <summary>
        /// 消息
        /// </summary>
        public string message { get; set; }
        /// <summary>
        /// 返回标志值
        /// </summary>
        public SimpleResultCode statusCode { get; set; }

        /// <summary>
        /// 跳转界面
        /// </summary>
        public string redirectUrl { get; set; }

        /// <summary>
        /// 错误结果
        /// </summary>
        /// <param name="message"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static SimpleResult GetError(string message = "操作失败", string url = null)
        {
            return new SimpleResult()
            {
                statusCode = SimpleResultCode.Error,
                message = message,
                redirectUrl = url
            };
        }

        /// <summary>
        /// 正确结果
        /// </summary>
        /// <param name="message"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static SimpleResult GetRight(string message="操作成功", string url = null)
        {
            return new SimpleResult()
            {
                statusCode = SimpleResultCode.Success,
                message = message,
                redirectUrl = url
            };
        }

        /// <summary>
        /// 超时结果
        /// </summary>
        /// <param name="message"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static SimpleResult GetTimeOut(string message="操作超时", string url = null)
        {
            return new SimpleResult()
            {
                statusCode = SimpleResultCode.Timeout,
                message = message,
                redirectUrl = url
            };
        }
    }

    public enum SimpleResultCode
    {
        Success = 200,
        Error = 300,
        Timeout = 301
    }

}
